package com.simple.gateway.center.domian.application.bo;

import com.simple.gateway.center.basedata.po.ApplicationInterface;
import com.simple.gateway.center.domian.application.dto.ApplicationInterfaceDTO;
import com.simple.gateway.center.domian.application.param.ApplicationInterfaceParam;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * 项目: simple-gateway-core
 *
 * 功能描述:
 *
 * @author: WuChengXing
 *
 * @create: 2023-08-07 17:12
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class ApplicationInterfaceBO {

    private Long id;

    /**
     * 系统标识
     */
    private String systemId;
    /**
     * 接口标识
     */
    private String interfaceId;
    /**
     * 接口名称
     */
    private String interfaceName;
    /**
     * 接口名称类型
     */
    private String interfaceType;
    /**
     * 接口版本
     */
    private String interfaceVersion;

    /**
     * 扩展字段
     */
    private String extension;

    private List<ApplicationInterfaceMethodBO> applicationInterfaceMethodBOS;

    public static ApplicationInterfaceBO do2Bo(ApplicationInterface applicationInterface) {
        return ApplicationInterfaceBO.builder()
                .id(applicationInterface.getId())
                .systemId(applicationInterface.getSystemId())
                .interfaceId(applicationInterface.getInterfaceId())
                .interfaceName(applicationInterface.getInterfaceName())
                .interfaceType(applicationInterface.getInterfaceType())
                .interfaceVersion(applicationInterface.getInterfaceVersion())
                .extension(applicationInterface.getExtension())
                .build();
    }

    public static ApplicationInterface bo2Do(ApplicationInterfaceBO applicationInterfaceBO) {
        ApplicationInterface applicationInterface = new ApplicationInterface();
        applicationInterface.setSystemId(applicationInterfaceBO.getSystemId());
        applicationInterface.setId(applicationInterfaceBO.getId());
        applicationInterface.setInterfaceId(applicationInterfaceBO.getInterfaceId());
        applicationInterface.setInterfaceName(applicationInterfaceBO.getInterfaceName());
        applicationInterface.setInterfaceType(applicationInterfaceBO.getInterfaceType());
        applicationInterface.setInterfaceVersion(applicationInterfaceBO.getInterfaceVersion());
        applicationInterface.setExtension(applicationInterfaceBO.getExtension());
        return applicationInterface;
    }

    public static ApplicationInterfaceDTO bo2Dto(ApplicationInterfaceBO applicationInterfaceBO) {
        ApplicationInterfaceDTO applicationInterface = new ApplicationInterfaceDTO();
        applicationInterface.setId(applicationInterfaceBO.getId());
        applicationInterface.setSystemId(applicationInterfaceBO.getSystemId());
        applicationInterface.setInterfaceId(applicationInterfaceBO.getInterfaceId());
        applicationInterface.setInterfaceName(applicationInterfaceBO.getInterfaceName());
        applicationInterface.setInterfaceType(applicationInterfaceBO.getInterfaceType());
        applicationInterface.setInterfaceVersion(applicationInterfaceBO.getInterfaceVersion());
        applicationInterface.setExtension(applicationInterfaceBO.getExtension());
        return applicationInterface;
    }

    public static ApplicationInterfaceBO param2Bo(ApplicationInterfaceParam applicationInterfaceParam) {
        ApplicationInterfaceBO bo = new ApplicationInterfaceBO();
        bo.setSystemId(applicationInterfaceParam.getSystemId());
        bo.setInterfaceId(applicationInterfaceParam.getInterfaceId());
        bo.setInterfaceName(applicationInterfaceParam.getInterfaceName());
        bo.setInterfaceVersion(applicationInterfaceParam.getInterfaceVersion());
        bo.setExtension(applicationInterfaceParam.getExtension());
        return bo;
    }
}
